<?php
/*
 * Created on 14.04.2007
 * @filesource: admin.extensionicons.html.php
 * @author: Nikolai Plath
 */


defined( '_VALID_MOS' ) or die( 'Direct Access to this script is not allowed');

class HTML_ExtensionIcons {

	function WrapMediaManager ()
	{
		echo '<div align="center" class="centermain">
	<div class="main">
				<style type="text/css">
		.previewFrame {
			border: none;
			width: 95%;
			height: 600px;
			padding: 0px 5px 0px 10px;
		}
		</style>

		<table class="adminform">
		<tr>
			<th width="50%" class="title">
			Media Manager
			</th>

		</tr>
		<tr>
			<td width="100%" valign="top" colspan="2">
			<iframe name="previewFrame" src="index3.php?option=com_media&amp;listdir=/ExtensionIcons_custom" class="previewFrame" /></iframe>
			</td>
		</tr>
		</table>
			</div>

</div>
';
	}
	function listItems ( $option, &$rows, &$pageNav ) {

    global $mosConfig_live_site, $mosConfig_absolute_path;
    global $mosConfig_lang;

if (file_exists($mosConfig_absolute_path .'/administrator/components/com_extensionicons/language/'.$mosConfig_lang.'.php')) {
	require_once ($mosConfig_absolute_path .'/administrator/components/com_extensionicons/language/'.$mosConfig_lang.'.php');
} else {
	require_once ($mosConfig_absolute_path .'/administrator/components/com_extensionicons/language/english.php');
}
    $number = count($rows);

	echo '
      <script language="javascript" type="text/javascript">
         function submitbutton(pressbutton) {
           var form = document.adminForm;
           if (pressbutton == "cancel") {
              submitform( pressbutton );
              return;
           }
           submitform( pressbutton );
        }
     </script>
     <h2><img src="images/credits.png" alt="Hi" />
     Extension Icons</h2>
    <form action="index2.php" method="post" name="adminForm">
      <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
       <tr>
        <th width="20">
         <input type="checkbox" name="toggle" value="" onclick="checkAll('.$number.');"/>
        </th>
        <th align="left" width="20">'._EXICONS_TIT_ICON.'</th>
        <th align="left">'._EXICONS_TIT_COMPONENT.'</th>
        <th align="left" colspan="2" width="40">'._EXICONS_TIT_SORT.'</th>
        <th align="center" width="20">'._EXICONS_TIT_PUBLISHED.'</th>
       </tr>';

        $cnt = 0;

		for ($i=0, $n=$number; $i < $n; $i++) {

			$row = &$rows[$i];
			$evenodd = $i % 2;
    	    $task 	= $row->published ? 'unpublish' : 'publish';
			$img 	= $row->published ? 'publish_g.png' : 'publish_x.png';
			$alt 	= $row->published ? 'Published' : 'Unpublished';

  			echo '
      <tr class="row'.$evenodd.'">
       <td>
        <input type="checkbox" id="cb'.$i.'" name="cid[]"
               value="'.$row->id.'"
               onclick="isChecked(this.checked);" />
       </td>
       <td>'
       	.'<img src="'.$mosConfig_live_site . '/includes/' . $row->admin_menu_img . '" />'
     .'</td>
        <td><strong>'.$row->parent_name.' </strong>'
        . '<a href="#edit" onclick="return listItemTask(\'cb'.$i.'\',\'edit\')">'
        .$row->name.'</a>
       </td>
      <td>';
	echo $pageNav->orderUpIcon( $i, ($row->catid == @$rows[$i-1]->catid) );
	echo '
		</td>
	  	<td>';
	echo $pageNav->orderDownIcon( $i, $n, ($row->catid == @$rows[$i+1]->catid) );

	echo '</td>';
	echo '<td align="center">';
    echo '<a href="javascript: void(0);" onclick="return listItemTask(\'cb'. $i .'\',\'' . $task . '\')">
		<img src="images/' . $img . '" width="12" height="12" border="0" alt="' . $alt . '" /></a>';
    echo "</td></tr>";

        }//fornext

	echo $pageNav->getListFooter();

	echo '
  	 </table>
      <input type="hidden" name="option"
             value="'.$option.'" />
      <input type="hidden" name="task" value="" />
      <input type="hidden" name="boxchecked" value="0" />
     </form>';
     }//function

  function edit( $option, &$row )
  {
global $mosConfig_live_site, $mosConfig_absolute_path;
global $mosConfig_lang;
mosCommonHTML::loadOverlib();

if (file_exists($mosConfig_absolute_path .'/administrator/components/com_extensionicons/language/'.$mosConfig_lang.'.php')) {
	require_once ($mosConfig_absolute_path .'/administrator/components/com_extensionicons/language/'.$mosConfig_lang.'.php');
} else {
	require_once ($mosConfig_absolute_path .'/administrator/components/com_extensionicons/language/english.php');
} ?>
  <script language="javascript" type="text/javascript">
        function submitbutton(pressbutton) {
           var form = document.adminForm;
           if (pressbutton == "cancel") {
              submitform( pressbutton );
              return;
           }
           submitform( pressbutton );
        }
     </script>
     <?php
echo '<form action="index2.php" method="post"
        name="adminForm" id="adminForm" class="adminForm">';

echo '<table class="adminheading">'
		. '<tr><th>'._EXICONS_TIT_EDIT.': <small>';
if ($row->name)
{
	echo $row->parent_name;
	if ($row->parent_name) echo ' - ';
	echo $row->name;
	echo ' <img src="../includes/' . $row->admin_menu_img . '" />';
} else
{
	echo _EXICONS_NEW_ITEM;
}
	echo '</small></th>'
		. '</tr></table>';

echo '<table class="adminform">';

/*
 * List Icons in /includes/js/ThemeOffice
 */
echo '<tr valign="top">'
 		. '<td style="text-align:right"><strong>'._EXICONS_TIT_ICON.':</strong>'.
// 		.'<img src="'.$mosConfig_live_site . '/includes/' . $row->admin_menu_img . '" />
		'<br />'
 		. mostooltip( _EXICONS_TOO_ICON ) .
		'</td>'
 		.'<td>';// .

$Pfad = '../includes/js/ThemeOffice/';
$sPfad = '/includes/js/ThemeOffice/';
$DD = dir($Pfad);
$icon_count = 0;
$icon_max   = 5;
echo '<table><tr><td>';
while (false !== ($entry = $DD->read()))
{
     if($entry != '.' && $entry != '..'
     	&& substr ($entry, strlen ($entry) -3) == 'png'
     	&& $entry != 'spacer.png'
     	&& $entry != 'blank.png')
     {
        echo '<label><input type="radio" name="admin_menu_img" value="js/ThemeOffice/' . $entry . '"';
       	if ('js/ThemeOffice/' . $entry == $row->admin_menu_img)
       	{
       		echo 'checked="checked"';
       	}
        echo		' />';
        echo '<img src="'.$mosConfig_live_site . $sPfad . $entry . '" />';
		echo '</label><br /><br />';
		$icon_count += 1;
     }
     if ( $icon_count == $icon_max )
     {
     	echo '</td><td>';
     	$icon_count = 0;
     }
}//while
echo '</td></tr>'
. '</table>';

/*
 * List images in custom_dir /images/exicons
 */
$Pfad = '../images/ExtensionIcons_custom/';
$sPfad = '/images/ExtensionIcons_custom/';

echo '<tr valign="top">'.
 		'<td style="text-align:right">' .
 		'<strong>'._EXICONS_TIT_ICON_PATH.':</strong>'.
 		'<br />' .
 		$Pfad.
 		'<br />' .
 		mostooltip( _EXICONS_TOO_ICON_PATH ) .
// 		.'<img src="'.$mosConfig_live_site . '/includes/' . $row->admin_menu_img . '" />
		'</td>'.
 		'<td>';// .
echo '<table><tr><td>';

if (is_dir($Pfad))
{
	$DD = dir($Pfad);
	$icon_count = 0;
	$iconTotal = 0;
	$icon_max   = 5;//number of icons to display: down
	while (false !== ($entry = $DD->read()))
	{
     	if($entry != '.' && $entry != '..'
	     	&& substr ($entry, strlen ($entry) -3) == 'png'
     		&& $entry != 'spacer.png'
     		&& $entry != 'blank.png')
     	{
	        echo '<label><input type="radio" name="admin_menu_img" value="'.$Pfad . $entry . '"';
       		if ( $Pfad . $entry == $row->admin_menu_img )
       		{
	       		echo 'checked="checked"';
       		}
        	echo		' />';
        	echo '<img src="'.$mosConfig_live_site . $sPfad . $entry . '" />';
			echo '</label><br /><br />';
			$icon_count += 1;
			$iconTotal+=1;
     	}
     	if ( $icon_count == $icon_max )
     	{
	     	echo '</td><td>';
     		$icon_count = 0;
     	}
  	}//while
  	if ( $iconTotal == 0 )
  	{
  		echo _EXICONS_NO_FILES_IN_DIR;
  	}
} else
{
	echo _EXICONS_DIR_NO_EXISTS;
}//if is_dir

echo '</td></tr>' .
	'</table>';

echo '<tr><td colspan="2"><hr /></td></tr>';

echo
		'</td>' .
		'</tr>';

echo	'<tr><td style="text-align:right">' .
		'<strong>' . _EXICONS_TIT_NAME . ' :</strong><br />'.
		mostooltip( _EXICONS_TOO_NAME ) .
		'</td><td><input type="text" name="name" value="' .
		 $row->name . '" />' .
		 '</td></tr>';

echo	'<tr><td style="text-align:right">' .
		'<strong>' . _EXICONS_TIT_OPTION . ' :</strong><br />'.
		mostooltip( _EXICONS_TOO_OPTION ) .
		'</td><td><input type="text" name="linkoption" value="' .
		 $row->linkoption . '" />' .
		 '</td></tr>';

echo	'<tr><td style="text-align:right">' .
		'<strong>' . _EXICONS_TIT_MENULINK . ' :</strong><br />'.
		mostooltip( _EXICONS_TOO_MENULINK ) .
		'</td><td><input type="text" name="admin_menu_link" value="' .
		 $row->admin_menu_link . '" />' .
		 '</td></tr>';

echo	'<tr><td style="text-align:right">' .
		'<strong>' . _EXICONS_TIT_MENUALT . ' :</strong><br />'.
		mostooltip( _EXICONS_TOO_MENUALT ) .
		'</td><td><input type="text" name="admin_menu_alt" value="' .
		 $row->admin_menu_alt . '" />' .
		 '</td></tr>';

//echo 	'<tr><td colspan="2"><hr /></td></tr>'
echo 	'<tr>'
			. '<td style="text-align:right"><strong>'._EXICONS_TIT_PUBLISHED.':</strong></td>'
			. '<td>'
			. mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published )
			. '</td>'
		. '</tr>';

echo 	'</table>';

echo	'<input type="hidden" name="id" value="' . $row->id . '" />
	    <input type="hidden" name="option" value="' . $option . '" />
   		<input type="hidden" name="task" value="" />
   </form>';
 }//function

 function help ( $option , $AppVersion )
 {
 global $mosConfig_absolute_path, $mosConfig_lang;

	if (file_exists ($mosConfig_absolute_path.'/administrator/components/com_extensionicons/language/help_'.$mosConfig_lang.'.php'))
	{
		require_once ($mosConfig_absolute_path.'/administrator/components/com_extensionicons/language/help_'.$mosConfig_lang.'.php');
	} else
	{
		require_once ($mosConfig_absolute_path.'/administrator/components/com_extensionicons/language/help_english.php');
	}
	HTML_ExtensionIcons::printFooter( $AppVersion );
 }

 function printFooter ( $AppVersion )
 {
	echo '<div class="smallgrey">' . $AppVersion . ' - ' . _EXICONS_GREETZ_NiK . ' <a href="http://www.nik-it.de">NiK-IT.de</a></div>';
 }//function

}//class
?>
